package com.yunqiao.admin.modules.api.controller;

import com.yunqiao.common.utils.PageUtils;
import com.yunqiao.common.utils.R;
import com.yunqiao.service.api.FundDetailService;
import com.yunqiao.service.api.entity.FundDetailEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 资金明细表
 *
 * @author Crocutax
 * @email wangxw725@163.com
 * @date 2019-03-02 15:03:56
 */
@RestController
@RequestMapping("api/funddetail")
public class FundDetailController {

    @Autowired
    private FundDetailService fundDetailService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("api:funddetail:list")
    public R list(@RequestParam Map<String, Object> params){
        params.put("sysType", true);
        PageUtils page = fundDetailService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("api:funddetail:info")
    public R info(@PathVariable("id") Integer id){
        FundDetailEntity fundDetail = fundDetailService.getById(id);
        return R.ok().put("fundDetail", fundDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("api:funddetail:save")
    public R save(@RequestBody FundDetailEntity fundDetail){
        fundDetailService.save(fundDetail);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("api:funddetail:update")
    public R update(@RequestBody FundDetailEntity fundDetail){
        fundDetailService.updateById(fundDetail);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("api:funddetail:delete")
    public R delete(@RequestBody Integer[] ids){
        fundDetailService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }


}
